const drawingApi = {
    /**
     * 绘画生成
     *
     * @param params
     * @author zero
     */
    generate(params: any): Promise<any> {
        return $request.post({
            url: '/apply/draws/drawing/generate',
            params
        })
    },

    /**
     * 绘画配置
     *
     * @param {string} engine 绘画引擎: [mj,sd,doubao,dalle]
     * @returns {Promise<DrawsConfigResponse>}
     * @author zero
     */
    config(engine: string): Promise<DrawsConfigResponse> {
        return $request.get({
            url: '/apply/draws/drawing/config',
            params: {
                engine
            }
        })
    },

    /**
     * 绘画记录
     *
     * @param params
     * @param {number} [params.page_no] - 当前页码
     * @param {number} [params.page_size] - 每页条数
     * @param {number} [params.status] - 绘画状态
     * @param {string} params.engine - 绘画引擎
     * @returns {Promise<DrawsRecordResponse[]>}
     * @author zero
     */
    record(params: {
        page_no?: number;
        page_size?: number;
        status?: number;
        engine: string;
    }): Promise<DrawsRecordResponse[]> {
        if (!params.status || params.status <= 0) {
            delete params.status
        }
        return $request.get<DrawsRecordResponse[]>({
            url: '/apply/draws/record/lists',
            params
        })
    },

    /**
     * 绘画检测
     *
     * @param {string[]} ids
     * @returns {Promise<DrawsRecordResponse[]>}
     * @author zero
     */
    detection(ids: string[]): Promise<DrawsRecordResponse[]> {
        return $request.post<DrawsRecordResponse[]>({
            url: '/apply/draws/record/detection',
            params: {
                ids
            }
        })
    },

    /**
     * 绘画记录删除
     *
     * @param {string} code
     * @returns {Promise<any>}
     * @author zero
     */
    delete(code: string): Promise<any> {
        return $request.post({
            url: '/apply/draws/record/delete',
            params: {
                code
            }
        })
    },

    /**
     * 绘画广场分享
     *
     * @param {string} code
     * @returns {Promise<any>}
     * @author zero
     */
    square(code: string): Promise<any> {
        return $request.post({
            url: '/apply/draws/record/square',
            params: {
                code
            }
        })
    },

    /**
     * 绘画记录收藏
     *
     * @param {string} code
     * @returns {Promise<any>}
     * @author zero
     */
    collect(code: string): Promise<any> {
        return $request.post({
            url: '/apply/draws/record/collect',
            params: {
                code
            }
        })
    }
}

export default drawingApi
